New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactored module exports; #5162
Conversation
Added module exports tests; Added missing ESM export for parity with Axios factory; Added `toFormData`, `formToJSON`, `isAxiosError`, `spread`, `isCancel`, `all` as named export to `index.d.ts`;
Promise.resolve(2) | ||
]; | ||
|
||
const promise: Promise<number[]> = all(promises); |
Check notice
Code scanning / CodeQL
Unused variable, import, function or class
// axios.spread named export | ||
(() => { | ||
const fn1 = (a: number, b: number, c: number) => `${a}-${b}-${c}`; | ||
const fn2: (arr: number[]) => string = spread(fn1); |
Check notice
Code scanning / CodeQL
Unused variable, import, function or class
// named export | ||
|
||
if (isAxiosError(error)) { | ||
const axiosError: AxiosError = error; |
Check notice
Code scanning / CodeQL
Unused variable, import, function or class
Added missed `CanceledError` & `AxiosHeaders` to `AxiosStatic` interface;
it('should be able to be loaded with import', async function () { | ||
this.timeout(30000); | ||
|
||
await exec(`npm test --prefix ${pkgPath}`); |
Check warning
Code scanning / CodeQL
Shell command built from environment values
it('should be able to be loaded with import', async function () { | ||
this.timeout(30000); | ||
|
||
await exec(`npm test --prefix ${pkgPath}`, {}); |
Check warning
Code scanning / CodeQL
Shell command built from environment values
What is the process for these getting released? Is there a regular release cadence? Or is it waiting for some magic? Or does it happen manually when there's enough to warrant a release? |
@jasonsaayman Can we have a pre-release with this PR like |
@KrayzeeKev no there is no set schedule. I would like to implement something like that but it is pretty hard as I also have work to attend too. I will look into doing something like a monthly schedule. @DigitalBrainJS yeah sure, the only problem is it will get very little traction, for the entire time we pre-released v1 we got 3000 downloads, pretty sure about 200 were my own projects. |
But yeah I will cut it as mentioned this weekend. |
@jasonsaayman Thx. I'm with you on the whole pre-release thing. We can't use them. It's |
I've managed to pull this version in using https but our code has always used: require('axios').default; |
@KrayzeeKev They are equivalent: module.exports = axios;
module.exports.default = axios; Just re-added support for this for backward compatibility in #5225 . |
@DigitalBrainJS Thanks. Easy to fix on our end too. Now I have to go back through the tickets that this merge is supposed to fix so I can tell everybody which ones it doesn't (axios-retry still broken with a function body in an http header) |
Brief description:
require
can only be used withdefault
export as it was in 0.x versions;import
can be used with bothdefault
&named
exports;Detailed:
toFormData
,formToJSON
,isAxiosError
,spread
,isCancel
,all
as named export toindex.d.ts
;In an attempt to bring order, the package export has been refactored. The following rules were adopted:
./lib/axios.js
./index.js
. This module should expand Axios factory export as ESM named export. This module should not be used for purposes other than re-export features as a named export../dist/axios.js
and./dist/esm/axios.js
bundles are for CDN usage only.Closes #5154; Closes #5164; Closes #5169; Closes #5091; Closes #5130; Closes #5118; Closes #5011; Closes #5031; Closes #5044; Closes #5082;
Related: #5101, #5026, #5088
Users that import the module with
require
will do it as it was before:If the module is loaded with
import
statement you can use both named and factory exports:OR
If something goes wrong (custom/outdated environment), you can try to load CommonJS bundle directly: